<?php
$connect = mysql_connect("localhost","root","");
$selectSQL = mysql_select_db("new");
mysql_query("set names utf8");

$mail = @$_POST["mail"];
$tele = @$_POST["tele"];
$pass = @$_POST["pass"];
$imgFile = @$_FILES["myFile"];

if ($imgFile != NULL){
	$headImgName = $tele;
	$imgType = $imgFile["type"];
	$type = explode("/",$imgType)[1];
	$imgUrl =  "headImg/".$headImgName.'.'.$type;    
}
     

move_uploaded_file($imgFile["tmp_name"], $imgUrl);


//获取时间
date_default_timezone_set("PRC");
$time = time();
$rTime = date("Y-m-d H:i:s",$time);

//查询数据库数据,是否被注册
$sql = "SELECT * FROM WYNews WHERE Email = '{$mail}' OR tele = '{$tele}'";
$result = mysql_query($sql);
if(mysql_affected_rows()>0){
	$arr = array('msg' => 0);
}else{
	$sql = "INSERT INTO WYNews(id,Email,tele,pass,headImgUrl,rTime) VALUES (NULL,'{$mail}','{$tele}','{$pass}','{$imgUrl}','{$rTime}')";
	$result = mysql_query($sql);
	if(mysql_affected_rows()>0){
		$arr = array('msg' =>1);
	}
}
echo json_encode($arr);





?>